package com.twu.biblioteca;

import java.io.BufferedReader;
import java.io.IOException;

/**
 * Created with IntelliJ IDEA.
 * User: Thoughtworker
 * Date: 8/22/13
 * Time: 10:29 AM
 * To change this template use File | Settings | File Templates.
 */
public class Input {
    private BufferedReader bufferedReader;

    public Input(BufferedReader bufferedReader) {
        this.bufferedReader = bufferedReader;
    }


    public int getUserInput() {
        int index;

        try {
            index = Integer.parseInt(bufferedReader.readLine());
        } catch (NumberFormatException e) {
            index = -1;  //To change body of catch statement use File | Settings | File Templates.
        } catch (IOException e) {
            index = -1;
        }

        return index;
    }


    public String getUserStringInput() {
        String input;
        try {
            input = bufferedReader.readLine();
        }  catch (IOException e) {
            input = null;
        }
       return input;
    }
}
